package com.woniuxy.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;


import java.util.ArrayList;
import java.util.List;


/**
 * @author 佘赛飞
 * @create 2021-11-18 1:49 下午
 */
@Controller
@RequestMapping("/ruser")
public class StringController {

    @RequestMapping("/addUser")
    public ModelAndView addUser(@RequestParam("name") String username,
                                @RequestParam String password,
                                Integer verificationCode){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("username", "传入的名字是："+username);
        modelAndView.addObject("password", "传入的密码是："+password);
        modelAndView.addObject("verificationCode","传入的验证码是:"+verificationCode);
        modelAndView.setViewName("stringview");
        return modelAndView;
    }
    /*
    数组
    * */
    @RequestMapping("/deleteUsers")
    public ModelAndView deleteUsers(int[] ids){
        ModelAndView modelAndView = new ModelAndView();
        List<Integer> list = new ArrayList <>();
        for(int id:ids){
            list.add(id);
        }
        modelAndView.addObject("ids","传入的数组是:"+list);
        modelAndView.setViewName("arrayview");
        return modelAndView;
    }

}
